import 'package:flutter/material.dart';

class DialogShowPage extends StatefulWidget {
  Function ? unlockFunction;
  DialogShowPage({super.key, required this.unlockFunction});

  @override
  State<DialogShowPage> createState() => _DialogShowPageState();
}

class _DialogShowPageState extends State<DialogShowPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('DialogShowPage'),
      ),
      body: Center(
        child: ElevatedButton(
          child: Text('Show Dialog'),
          onPressed: () {
            showDialog(
              context: context,
              builder: (BuildContext context) {
                return AlertDialog(
                  title: Text('Dialog Title'),
                  content: Text('Dialog Content'),
                  actions: [
                    TextButton(
                      child: Text('Cancel'),
                      onPressed: () {
                        Navigator.of(context).pop();
                      }
                    ),
                    TextButton(
                      child: Text('OK'),
                      onPressed: () {
                        //回到上上页面
                        Navigator.of(context).pop();
                        Navigator.of(context).pop();
                        if (widget.unlockFunction != null) {
                          widget.unlockFunction!();
                        }
                      }
                    )
                  ]
                );
              }
            );
          }
        )
      )
    );
  }
}
